//
//  LYHelpViewController.m
//  artist
//
//  Created by Jay_Apple on 16/4/13.
//  Copyright © 2016年 viviyoo. All rights reserved.
//

#import "LYHelpViewController.h"

@interface LYHelpViewController ()
@property (weak, nonatomic) IBOutlet UITextView *content;
@property (weak, nonatomic) IBOutlet UITextField *connect;
@property (weak, nonatomic) IBOutlet UILabel *placeHolder;

@end

@implementation LYHelpViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (void)sendSuggestion{

    
    [LYRequestTool sendSuggestionWithToken:LYToken content:self.content.text contact:self.connect.text success:^{
        
        [MBProgressHUD showSuccess:@"提交成功"];
        [self.navigationController popViewControllerAnimated:YES];
        
    } failure:^(NSString *code, NSString *message) {
        
        [MBProgressHUD showError:message];
        
    }];

}



- (IBAction)commit:(id)sender {
    
    
    if (self.content.text.length == 0) {
        [MBProgressHUD showOnlyText:@"请输入您的意见"];
        return;
    }
    if (self.connect.text.length == 0) {
        [MBProgressHUD showOnlyText:@"请输入您的联系方式"];
        return;
    }
    
    [self sendSuggestion];
    
}

#pragma mark - textViewDelegate


- (void)textViewDidChangeSelection:(UITextView *)textView{
    
    if (textView.text.length == 0) {
        self.placeHolder.hidden = NO;
    }else{
        self.placeHolder.hidden = YES;
    }
}

@end
